{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8795db3a-af9a-4f03-a68d-019330861b54",
   "metadata": {},
   "source": [
    "A notebook that use [GoNB](https://github.com/janpfeifer/gonb)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "50a2fb21-01b3-46d0-9951-f9a1301a85ca",
   "metadata": {},
   "source": [
    "the code below comes from [tutorial.ipynb](https://github.com/janpfeifer/gonb/blob/main/examples/tutorial.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75d8418d-a918-4cc8-b42e-384db01f21ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "func main() {\n",
    "    fmt.Printf(\"Hello World!\")\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3620f46f-efd5-4454-bc29-418297012ce9",
   "metadata": {},
   "outputs": [],
   "source": [
    "%%\n",
    "fmt.Printf(\"Hello World!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fed4a43",
   "metadata": {},
   "source": [
    "%% --who=world can pass flags to main func"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "473e2d02",
   "metadata": {},
   "outputs": [],
   "source": [
    "import (\n",
    "    \"flag\"\n",
    "    \"fmt\"\n",
    ")\n",
    "\n",
    "var flagWho = flag.String(\"who\", \"\", \"Your name!\")\n",
    "\n",
    "%% --who=world\n",
    "fmt.Printf(\"Hello %s!\\n\", *flagWho)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8e8b4ae",
   "metadata": {},
   "source": [
    "%args also can pass flags"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "348efbe1",
   "metadata": {},
   "outputs": [],
   "source": [
    "%args --who=Wally\n",
    "\n",
    "func main() {\n",
    "    flag.Parse()\n",
    "    fmt.Printf(\"Where is %s?\", *flagWho)\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "82f4bb1f-3311-4fca-8025-c54c0305dc64",
   "metadata": {},
   "outputs": [],
   "source": [
    "import \"github.com/janpfeifer/gonb/gonbui\"\n",
    "\n",
    "%%\n",
    "gonbui.DisplayHtml(`<span style=\"background:pink; color:#111; border-radius: 3px; border: 3px solid orange; font-size: 18px;\">I 🧡 GoNB!</span>`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1a5584ff-f346-45cf-95c1-a3e3b7146c6c",
   "metadata": {},
   "outputs": [],
   "source": [
    "%%\n",
    "gonbui.DisplayMarkdown(\"#### Objective\\n\\n1. Have fun coding **Go**;\\n1. Profit...\\n\"+\n",
    "                       `$$f(x) = \\int_{-\\infty}^{\\infty} e^{-x^2} dx$$`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de996381-d92c-4ce6-a135-50cf39288aa1",
   "metadata": {},
   "outputs": [],
   "source": [
    "func init_a() {\n",
    "    fmt.Println(\"init_a\")\n",
    "}\n",
    "%%\n",
    "fmt.Println(\"main\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go (gonb)",
   "language": "go",
   "name": "gonb"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.21.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
